Skip to content

[AutoDiff] Fix derivative forwarding thunk linkage. #31726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2020

Conversation

dan-zheng
Copy link
Contributor

@dan-zheng dan-zheng commented May 12, 2020

Make derivative forwarding thunks use original function's linkage instead of the
derivative function's, stripping external.

This is consistent with the linkage of differentiability witnesses.

Clarify AutoDiff linkage-related comments.

Resolves TF-1160: TBDGen error due to incorrect derivative thunk linkage.


import _Differentiation

func internalOriginal(_ x: Float) -> Float { x }

@usableFromInline
@derivative(of: internalOriginal)
func usableFromInlineDerivative(_ x: Float) -> (value: Float, pullback: (Float) -> Float) {
  (x, { $0 })
}

Before:

$ swiftc tf-1160.swift
<unknown>:0: error: symbol 'AD__$s4main16internalOriginalyS2fF__vjp_src_0_wrt_0' (AD__$s4main16internalOriginalyS2fF__vjp_src_0_wrt_0) is in generated IR file, but not in TBD file
<unknown>:0: error: please file a radar or open a bug on bugs.swift.org with this code, and add -Xfrontend -validate-tbd-against-ir=none to squash the errors

After: no error.

Make derivative forwarding thunks use original function's linkage instead of the
derivative function's, stripping external.

This is consistent with the linkage of differentiability witnesses.

Clarify AutoDiff linkage-related comments.

Resolves TF-1160: AutoDiff symbol TBDGen error.
@dan-zheng dan-zheng marked this pull request as ready for review May 12, 2020 07:21
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ec38ce6

@dan-zheng
Copy link
Contributor Author

There was a watchsimulator-i386 CI failure:

02:02:24 Failing Tests (1):
02:02:24     Swift(watchsimulator-i386) :: AutoDiff/compiler_crashers_fixed/sr12650-noderivative-parameter-type-mangling.swift
02:02:12 ******************** TEST 'Swift(watchsimulator-i386) :: AutoDiff/compiler_crashers_fixed/sr12650-noderivative-parameter-type-mangling.swift' FAILED ********************
02:02:12 Script:
02:02:12 --
02:02:12 : 'RUN: at line 1';   xcrun --toolchain default --sdk '/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator6.2.sdk' /Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/buildbot_incremental/swift-macosx-x86_64/bin/swiftc -target i386-apple-watchos2.0-simulator  -module-cache-path '/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/buildbot_incremental/swift-macosx-x86_64/swift-test-results/i386-apple-watchos2.0-simulator/clang-module-cache' -F '/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/Library/Frameworks' -toolchain-stdlib-rpath  -swift-version 4  -Xfrontend -ignore-module-source-info  -g /Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/swift/test/AutoDiff/compiler_crashers_fixed/sr12650-noderivative-parameter-type-mangling.swift
02:02:12 --
02:02:12 Exit Code: 1
02:02:12 
02:02:12 Command Output (stderr):
02:02:12 --
02:02:12 ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/Library/Frameworks'
02:02:12 error: cannot parse the debug map for 'main': No such file or directory
02:02:12 <unknown>:0: error: generate-dSYM command failed with exit code 1 (use -v to see invocation)

I suspect it's a flake.

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test macOS

@dan-zheng dan-zheng merged commit 7fbfbc5 into swiftlang:master May 12, 2020
@dan-zheng dan-zheng deleted the TF-1160-linkage branch May 12, 2020 13:07
rxwei pushed a commit to rxwei/swift that referenced this pull request Jun 3, 2020
Make derivative forwarding thunks use original function's linkage instead of the
derivative function's, stripping external.

This is consistent with the linkage of differentiability witnesses.

Clarify AutoDiff linkage-related comments.

Resolves TF-1160: TBDGen error due to incorrect derivative thunk linkage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants